﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace APNotifications.Dialog
{
    public partial class frmSoundSettings : Form
    {
        private string btnSelected = string.Empty;

        public frmSoundSettings()
        {
            InitializeComponent();
        }

        private void btnMess_Click(object sender, EventArgs e)
        {
            try
            {
                btnSelected = "btnMess";
                openFileDialog1.ShowDialog();
            }
            catch
            {
            }
            
        }

        private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
        {
            try
            {
                if (btnSelected == "btnMess")
                    txtMess.Text = openFileDialog1.FileName;
                if (btnSelected == "btnPokes")
                    txtPokes.Text = openFileDialog1.FileName;
                if (btnSelected == "btnFriendReq")
                    txtFriendReq.Text = openFileDialog1.FileName;
                if (btnSelected == "btnGroupInv")
                    txtGroupInv.Text = openFileDialog1.FileName;
                if (btnSelected == "btnEventInv")
                    txtEventInv.Text = openFileDialog1.FileName;
            }
            catch
            {
            }
        }

        private void btnPokes_Click(object sender, EventArgs e)
        {
            try
            {
                btnSelected = "btnPokes";
                openFileDialog1.ShowDialog();
            }
            catch
            {
            }

        }

        private void btnFriendReq_Click(object sender, EventArgs e)
        {
            try
            {
                btnSelected = "btnFriendReq";
                openFileDialog1.ShowDialog();
            }
            catch
            {
            }
        }

        private void btnGroupInv_Click(object sender, EventArgs e)
        {
            try
            {
                btnSelected = "btnGroupInv";
                openFileDialog1.ShowDialog();
            }
            catch
            {
            }
        }

        private void btnEventInv_Click(object sender, EventArgs e)
        {
            try
            {
                btnSelected = "btnEventInv";
                openFileDialog1.ShowDialog();
            }
            catch
            {
            }
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtMess.Text.Trim().Length > 0)
            {
                Config.SaveSoundUnreadMess(txtMess.Text.Trim());
            }
            if (txtPokes.Text.Trim().Length > 0)
            {
                Config.SaveSoundPoke(txtPokes.Text.Trim());
            }
            if (txtFriendReq.Text.Trim().Length > 0)
            {
                Config.SaveSoundFriendReq(txtFriendReq.Text.Trim());
            }
            if (txtGroupInv.Text.Trim().Length > 0)
            {
                Config.SaveSoundGroupInv(txtGroupInv.Text.Trim());
            }
            if (txtEventInv.Text.Trim().Length > 0)
            {
                Config.SaveSoundEventInv(txtEventInv.Text.Trim());
            }

            this.Close();
        }

        private void frmSoundSettings_Load(object sender, EventArgs e)
        {
            try
            {
                txtMess.Text = Config.SoundUnreadMess();
                txtPokes.Text = Config.SoundPoke();
                txtFriendReq.Text = Config.SoundFriendReq();
                txtGroupInv.Text = Config.SoundGroupInv();
                txtEventInv.Text = Config.SoundEventInv();
            }
            catch
            {

            }
        }
    }
}
